Skip to contentSkip to conversation

Change in openvpn[master]: openvpnmscia: Improve check of vsnprintf return value

Openvpn-devel In review flichtenheld (Code Review) 2 participants 6 messages Jan 30 – Mar 10 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): gerrit.1769789455000.Ia57fa6d2469be08343c0457dd0213f062bc4cfa5@...2715...

#1 lore raw

Attention is currently required from: plaisthos.

Hello plaisthos,

I'd like you to do a code review.
Please visit

    http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email

to review the following change.

Change subject: openvpnmscia: Improve check of vsnprintf return value
......................................................................

openvpnmscia: Improve check of vsnprintf return value

Avoid sign-compare warning and do not ignore error return values.

Change-Id Ia57fa6d2469be08343c0457dd0213f062bc4cfa5

---
M src/openvpnmsica/dllmain.c

1 file changed, 1 insertion(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/1504/1

src/openvpnmsica/dllmain.c +1 -10
index 2bb0e1b..85ebda9 100644
@@ -98,11 +98,6 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 void
 x_msg_va(const unsigned int flags, const char *format, va_list arglist)
 {
@@ -124,7 +119,7 @@
         /* Field 2: The message string. */
         char szBufStack[128];
         int iResultLen = vsnprintf(szBufStack, _countof(szBufStack), format, arglist);
-        if (iResultLen < _countof(szBufStack))
+        if (iResultLen > 0 && (unsigned int)iResultLen < _countof(szBufStack))
         {
             /* Use from stack. */
             MsiRecordSetStringA(hRecordProg, 2, szBufStack);
@@ -194,7 +189,3 @@
                       hRecordProg);
     MsiCloseHandle(hRecordProg);
 }
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia57fa6d2469be08343c0457dd0213f062bc4cfa5
Gerrit-Change-Number: 1504
Gerrit-PatchSet: 1
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>

#2 lore raw
In reply to a message not in the archive

Attention is currently required from: flichtenheld, plaisthos.

cron2 has posted comments on this change by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email )

Change subject: openvpnmscia: Improve check of vsnprintf return value
......................................................................

Patch Set 6: Code-Review+2

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia57fa6d2469be08343c0457dd0213f062bc4cfa5
Gerrit-Change-Number: 1504
Gerrit-PatchSet: 6
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Sat, 07 Mar 2026 09:16:17 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes

#3 lore raw

PATCH v6 1/1 openvpnmscia: Improve check of vsnprintf return value

In reply to a message not in the archive

From: Frank Lichtenheld <[email protected]...>

Avoid sign-compare warning and do not ignore error return values.

Change-Id Ia57fa6d2469be08343c0457dd0213f062bc4cfa5

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1504
---

This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1504
This mail reflects revision 6 of this Change.

Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>

src/openvpnmsica/dllmain.c +1 -10
index 2bb0e1b..85ebda9 100644
@@ -98,11 +98,6 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 void
 x_msg_va(const unsigned int flags, const char *format, va_list arglist)
 {
@@ -124,7 +119,7 @@
         /* Field 2: The message string. */
         char szBufStack[128];
         int iResultLen = vsnprintf(szBufStack, _countof(szBufStack), format, arglist);
-        if (iResultLen < _countof(szBufStack))
+        if (iResultLen > 0 && (unsigned int)iResultLen < _countof(szBufStack))
         {
             /* Use from stack. */
             MsiRecordSetStringA(hRecordProg, 2, szBufStack);
@@ -194,7 +189,3 @@
                       hRecordProg);
     MsiCloseHandle(hRecordProg);
 }
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: openvpnmscia: Improve check of vsnprintf return value

Straightforward enough :-)

Your patch has been applied to the master branch.

commit 2a8db969ab9fdc4b0ebd154ac2376f3bf8c3d811

Author: Frank Lichtenheld
Date:   Sat Mar 7 10:16:44 2026 +0100
     openvpnmscia: Improve check of vsnprintf return value

     Signed-off-by: Frank Lichtenheld <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1504
     Message-Id: <[email protected]...>
     URL: https://www.mail-archive.com/[email protected]/msg35972.html
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw
In reply to a message not in the archive

cron2 has uploaded a new patch set (#7) to the change originally created by flichtenheld. ( http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email )

The following approvals got outdated and were removed:
Code-Review+2 by cron2

Change subject: openvpnmscia: Improve check of vsnprintf return value
......................................................................

openvpnmscia: Improve check of vsnprintf return value

Avoid sign-compare warning and do not ignore error return values.

Change-Id Ia57fa6d2469be08343c0457dd0213f062bc4cfa5

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1504
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35972.html

---
M src/openvpnmsica/dllmain.c

1 file changed, 1 insertion(+), 10 deletions(-)

git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/04/1504/7

src/openvpnmsica/dllmain.c +1 -10
index 2bb0e1b..85ebda9 100644
@@ -98,11 +98,6 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 void
 x_msg_va(const unsigned int flags, const char *format, va_list arglist)
 {
@@ -124,7 +119,7 @@
         /* Field 2: The message string. */
         char szBufStack[128];
         int iResultLen = vsnprintf(szBufStack, _countof(szBufStack), format, arglist);
-        if (iResultLen < _countof(szBufStack))
+        if (iResultLen > 0 && (unsigned int)iResultLen < _countof(szBufStack))
         {
             /* Use from stack. */
             MsiRecordSetStringA(hRecordProg, 2, szBufStack);
@@ -194,7 +189,3 @@
                       hRecordProg);
     MsiCloseHandle(hRecordProg);
 }
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia57fa6d2469be08343c0457dd0213f062bc4cfa5
Gerrit-Change-Number: 1504
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>

#6 lore raw
In reply to a message not in the archive

cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email )

Change subject: openvpnmscia: Improve check of vsnprintf return value
......................................................................

openvpnmscia: Improve check of vsnprintf return value

Avoid sign-compare warning and do not ignore error return values.

Change-Id Ia57fa6d2469be08343c0457dd0213f062bc4cfa5

Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1504
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg35972.html

---
M src/openvpnmsica/dllmain.c

1 file changed, 1 insertion(+), 10 deletions(-)
src/openvpnmsica/dllmain.c +1 -10
index 2bb0e1b..85ebda9 100644
@@ -98,11 +98,6 @@
     return true;
 }
 
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wsign-compare"
-#endif
-
 void
 x_msg_va(const unsigned int flags, const char *format, va_list arglist)
 {
@@ -124,7 +119,7 @@
         /* Field 2: The message string. */
         char szBufStack[128];
         int iResultLen = vsnprintf(szBufStack, _countof(szBufStack), format, arglist);
-        if (iResultLen < _countof(szBufStack))
+        if (iResultLen > 0 && (unsigned int)iResultLen < _countof(szBufStack))
         {
             /* Use from stack. */
             MsiRecordSetStringA(hRecordProg, 2, szBufStack);
@@ -194,7 +189,3 @@
                       hRecordProg);
     MsiCloseHandle(hRecordProg);
 }
-
-#if defined(__GNUC__) || defined(__clang__)
-#pragma GCC diagnostic pop
-#endif

--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1504?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email

Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ia57fa6d2469be08343c0457dd0213f062bc4cfa5
Gerrit-Change-Number: 1504
Gerrit-PatchSet: 7
Gerrit-Owner: flichtenheld <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: plaisthos <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>